package ihuotui.ftl.html;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public class Utils {
	public static List<String> getNames(Class<?> clazz) {
		List<String> names = null;
		try {
			Class<?> cls = Class.forName(clazz.getName());
			Object objectBean = cls.newInstance();
			Field[] fields = objectBean.getClass().getDeclaredFields();
			names = new ArrayList<String>(fields.length);
			// Map<String, String> hash = new LinkedHashMap<String,
			// String>(fields.length);
			for (Field field : fields) {
				// try {
				// Method method = objectBean.getClass().getMethod("get" +
				// methodName(field.getName()));
				names.add(field.getName());
				// } catch (NoSuchMethodException e) {
				// continue;
				// }
			}
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return names;
	}

	public static String methodName(String name) {
		return name.substring(0, 1).toUpperCase() + name.substring(1, name.length());
	}
}
